07. Quiz: List Methods

Quiz: len, max, min, and Lists

There is a Python environment for you to run test code at the bottom of this page related to any of the quizzes on this page!

len, max, and min

What would the output of the following code be? (Treat the comma in the multiple choice answers as newlines.)

a = [1, 5, 8]
b = [2, 6, 9, 10]
c = [100, 200]

print(max([len(a), len(b), len(c)]))
print(min([len(a), len(b), len(c)]))
SOLUTION: 4, 2

Quiz: sorted, join, and Lists

sorted and join

What would the output of the following code be? (Treat the comma in the multiple choice answers as newlines.)

names = ["Carol", "Albert", "Ben", "Donna"]
print(" & ".join(sorted(names)))
SOLUTION: Albert & Ben & Carol & Donna

Quiz: append and Lists

What would the output of the following code be? (Treat the commas in the multiple choice answers as newlines.)

names = ["Carol", "Albert", "Ben", "Donna"]
names.append("Eugenia")
print(sorted(names))
SOLUTION: ['Albert', 'Ben', 'Carol', 'Donna', 'Eugenia']

List Method Playground

Start Quiz:

# Use this playground to experiment with list methods, using Test Run